package com.icss.View;

import com.icss.dao.DeptFileDao;
import com.icss.dao.IDeptFileDao;
import com.icss.entity.Dept;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class MainFileView {
    Scanner scanner = null;

 IDeptFileDao deptFileDao = new DeptFileDao();


    public static void main(String[] args) {
        MainFileView mainFileView = new MainFileView();
        mainFileView.topView();
    }


    private void topView() {
        System.out.println("欢迎使用人力资源管理系统");
        System.out.println("==================================");
        System.out.println("部门管理-------------------------1");
        System.out.println("员工管理-------------------------2");
        System.out.println("程序退出-------------------------3");
        scanner  = new Scanner(System.in);
        int chose = scanner.nextInt();
        switch(chose){
            case 1:
                depView();//调用部门管理的方法
                break;
            case 2:

                break;
            case 3:
                System.exit(0);
                break;
        }

    }
    //部门管理方法
    private void depView() {
        System.out.println("部门管理");
        System.out.println("========================================");
        System.out.println("添加部门-------------------------------1");
        System.out.println("修改部门-------------------------------2");
        System.out.println("删除部门-------------------------------3");
        System.out.println("查询所有部门-------------------------------4");
        System.out.println("返回首页---------------------------------5");
        scanner  = new Scanner(System.in);
        int chose = scanner.nextInt();
        switch(chose){
            case 1:
                addDeptView();
                break;
            case 2:

                break;
            case 3:

                break;
            case 4:

                break;
            case 5:
                topView();
                break;
        }

    }

    private void addDeptView() {
        System.out.println("请输入部门编号：");
        int deptNo = scanner.nextInt();
        System.out.println("请输入部门名称：");
        String deptName = scanner.next();
        System.out.println("请输入部门地址：");
        String deptLoc = scanner.next();
        Dept dept = new Dept(deptNo, deptName, deptLoc);
        deptFileDao.writeDept(dept);
        System.out.println("添加成功");
      //deptView();
    }


}
